#ifndef __APPLICATION_H__
#define __APPLICATION_H__

#include "../D3DRenderer/D3DRenderer.h"
#include "../D3DRenderer/VisualHelperManager.h"
#include "../D3DRenderer/FontManager.h"
using namespace Renderer;

#include "../DIWrapper/InputManager.h"
using namespace Input;

#include "ProtocolBuffers/OrbitingObject.pb.h"
using namespace google::protobuf;

#include "SphericubicMesh.h"

namespace Sphericubic
{
	//--------------------------------------------------------------------
	//--------------------------------------------------------------------
	//--------------------------------------------------------------------

	class Application
	{
	public:
		Application();
		~Application();

		HWND m_hWnd;

		D3DRenderer::VideoInfo	m_oVideoInfo;
		bool OpenVideo();
		void CloseVideo();

		bool CreateMesh(const unsigned int& _uSubdivisions, const float& _fScale);
		void ReleaseMesh();

		bool LoadCelestialData(const string& _strFilename);
		void UnloadCelestialData();
		void JumpToCelestialObject(const string& _strName);

		bool Update();

	protected:
		bool CreateOrbitingObject(const Message& _rMessage);
		void ComputeRotationAxis(Vector3& _rRotationAxis, const float& _fYaw, const float& _fPitch, const float& _fRoll) const;
		CelestialObject* GetCelestialObject(const string& _strName) const;
		CelestialObject::EType PBCelObjTypeToCelObjType(const PBOrbitingObject_EObjectType& _ePBCelObj) const;
		void OutputDebug(const string& _strText);

	protected:
		InputManager::RawKeyboardInfo	m_oRKI;
		InputManager::RawMouseInfo		m_oRMI;
		ViewManager						m_oViewManager;
		CelestialObjectPtrVec			m_vCelestialObjects;
		CelestialObjectPtrMap			m_mCelestialObjects;
		D3DRenderer*					m_pRenderer;
		SphericubicMesh*				m_pMesh;
		CelestialObject*				m_pLastJumpCelObj;
		CelestialObject*				m_pLocalSystemCelObj;
		VisualHelperManager*			m_pVisualHelperManager;
		FontManager*					m_pFontManager;
		Vector3							m_oMeshRotation;
		DWORD							m_uTickCount;
		float							m_fDeltaTime;
		float							m_fTimeFactor;
		float							m_fSpeedFactor;
		bool							m_bSnapToCelObj;
	};
}

#endif // __APPLICATION_H__
